﻿using System;
using System.Collections.Generic;
using System.Text;

namespace FDSimpleModelGenerator.Models
{
    /// <summary>
    /// 接口结果
    /// </summary>
    public class ApiResult
    {
        public ApiResultCode Code { get; private set; }

        public string Message { get; private set; }

        public static ApiResult Success(string message = "Ok")
        {
            return new ApiResult
            {
                Code = ApiResultCode.Success,
                Message = message
            };
        }

        public static ApiResult<T> Success<T>(T data, string message = "Ok")
        {
            return new ApiResult<T>
            {
                Code = ApiResultCode.Success,
                Message = message,
                Data = data
            };
        }

        public static ApiResult Failure(ApiResultCode code, string message)
        {
            return new ApiResult
            {
                Code = code,
                Message = message
            };
        }
    }

    public class ApiResult<T> : ApiResult
    {
        public T Data { get; set; }
    }
}
